#include "Socket.hpp"
#include "Service.hpp"
#include "TcpServer.hpp"

int main(int args, char *argv[])
{
    // 检查使用格式
    if (args != 2)
    {
        LOG(INFO, "Usage: %s localport\n", argv[0]);
        exit(0);
    }

    // 获取localport并传递给TcpServer构造
    uint16_t localport = std::stoi(argv[1]);

    IOService io_service;
    // 耦合了io_service和tcpserver
    std::unique_ptr<TcpServer> utsp = std::make_unique<TcpServer>(
        std::bind(&IOService::IOExcute, &io_service,
                  std::placeholders::_1,
                  std::placeholders::_2),
        localport);

    utsp->Start();

    return 0;
}